/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package edu.gatech.gellinservlet.model;
import java.util.ArrayList;

/**
 *
 * @author Hung
 */
public class SportTeam {
    private ArrayList<Player> playerList;
    private String name;
    private int maxSize;
    
    public SportTeam(String name, int maxSize){
        this.name = name;
        this.maxSize = maxSize;
        playerList = new ArrayList<Player>();
     }
    
    /**
     * Add a player to the this SportTeam
     * @param player The player to be added.
     * @return true if player was added
     * @return false if player was not added
     */
    public String add(Player player) 
    {
        if(player == null){
            return "null player";             
        }
        else if(findPlayer(player)){
            return "duplicate player";
        }
        else if(playerList.size() >= maxSize){
            return "max size";
        }
            
        playerList.add(player);
        return "added";
     }
    
    /** 
     * Dummy method used to check if a player is already on team
     * @return true player is already on team
     * @return false player is not on team 
     */  
        public boolean findPlayer(Player player){
            return player.isAlreadyOnTeam();
        }
}
